<%@ 
page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>

<%@page import="com.lovo.bbs.vo.*,com.lovo.bbs.bo.*,java.util.*"%>

<%
	//处理自动登入
	String cookieName = "";
	String cookiePassword = "";
	Cookie[] cookies = request.getCookies();
	if (cookies != null) {
		for (int i = 0; i < cookies.length; i++) {
			Cookie cookie = cookies[i];
			if (cookie.getName().equals("cookieName")) {
				cookieName = cookie.getValue();
			}
			if (cookie.getName().equals("cookiePassword")) {
				cookiePassword = cookie.getValue();
			}
		}
	// 封装登录信息
	LoginVo loginvo = new LoginVo();
	loginvo.setUserName(cookieName);
	loginvo.setPassword(cookiePassword);
	if(new LoginBo().checkUser(loginvo,LoginBo.TYPE_OF_MEMBER)){
	   // 记录用户已登录状态
	   session.setAttribute("loginvo", loginvo);
	   session.setAttribute("member", loginvo.getUserName());//普通用户
	   session.removeAttribute("admin");
	   session.removeAttribute("moderator");
	  }	
	}
	

	//取得所有板块列表
	ArrayList<BoardVo> boardList = (ArrayList<BoardVo>) request
			.getAttribute("boardList");

	//取得所有论坛列表
	ArrayList<ForumVo> forumList = (ArrayList<ForumVo>) request
			.getAttribute("forumList");

	//取得友情链接列表
	ArrayList<LinkVo> linkList = (ArrayList<LinkVo>) request
			.getAttribute("linkList");

	//论坛杂项信息
	ForumStatVo forumInfo = (ForumStatVo) request
			.getAttribute("forumInfo");
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
	<head>
		<title><%=forumInfo.getSiteName()%></title>

		<link href="css/style.css" type="text/css" rel="stylesheet" />
		<link href="css/menu.css" type="text/css" rel="stylesheet" />
		<link href="css/common.css" type="text/css" rel="stylesheet" />

		<script type="text/javascript" src="js/vbulletin_global.js"></script>
		<script type="text/javascript" src="js/vbulletin_menu.js"></script>
		<script type="text/javascript" src="js/wbs_common.js"></script>
		<script type="text/javascript" src="js/wbs_ajax.js"></script>
		<script type="text/javascript" src="js/wbs_popup.js"></script>
		<script type="text/javascript" src="js/wbs_dragdrop.js"></script>


	</head>


	<body>
		<div id="overlay">
		</div>
		<div id="popLayer" style="position: absolute; z-index: 101"
			class="cPopText">
		</div>
		<div>

			<!--登录状态与网站统计----------------------------------------------------------------->
			<table width="100%" align="center" cellpadding="0" cellspacing="1"
				class="CommonNavigation_OuterTableCSS">
				<tr>
					<td>
						<table width="100%" cellpadding="9" cellspacing="0">
							<tr>
								<td class="CommonNavigation_InnerTableFooterCSS">
									<table width="100%" cellpadding="0" cellspacing="0">
										<tr>
											<!--登录状态----------------------------------------------------------------->
											<td class="SmallTxt">
												<%
													if (session.getAttribute("loginvo") == null) {
												%>
												<font class="SmallGrayText">欢迎: <b>游客</b> </font>
												<font class="SmlLinks">( </font><a href="javascript:void(0)"
													onclick="openLogin()">登陆</a><font class="SmlLinks">
													| </font><a href="javascript:void(0)" onclick="openRegister()">注册</a><font
													class="SmlLinks"> )</font>


												<!--注册窗口----------------------------------------------------------------->
												<%@include file="include/regWindow.html"%>



												<%
													} else {
														LoginVo loginvo = (LoginVo) session.getAttribute("loginvo");
												%>
												欢迎:
												<em id="logedusername" value="<%=loginvo.getUserName()%>">
													<a href="userinfo.jsp?username=<%=loginvo.getUserName()%>"><%=loginvo.getUserName()%></a>
												</em>
												<font class="SmlLinks">( </font><a href="javascript:void(0)"
													onclick="logout()">退出</a><font class="SmlLinks"><font
													class="SmlLinks"> )</font>&nbsp;&nbsp; <a
													class="FunctionDesk"
													href="control/control.jsp?username=<%=loginvo.getUserName()%>">控制面板</a>
													<%
														}
													%>
												
											</td>


											<!--网站统计----------------------------------------------------------------->
											<td align="right" class="smalltext">
												<b><%=forumInfo.getTopicNum()%></b>主题/
												<b><%=forumInfo.getPostNum()%> </b>回帖 今日
												<b><%=forumInfo.getTodayTopicNum()%></b>主题
												<br>
												会员数:
												<b><%=forumInfo.getMemberNum()%></b>&nbsp;&nbsp; 在线会员数:
												<b><%=forumInfo.getMemberOLNum()%> </b>&nbsp;&nbsp; 在线总人数:
												<b><%=forumInfo.getUserOLNum()%> </b>&nbsp;&nbsp;
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>


			<font size="1"><br> </font>

			<!--网站公告 ----------------------------------------------------------------->
			<table cellpadding="7" width="100%" cellpadding="1" cellspacing="0"
				class="forum_out">
				<tr>
					<td class="forumcell_read">
						<marquee>
							<a><span class="smalltext"> <%=forumInfo.getSiteNotice()%>
							</span> </a>
						</marquee>
					</td>
				</tr>
			</table>



			<font size="1"><br> </font>
			<font size="1"><br> </font>


			<!--导航栏 ----------------------------------------------------------------->
			<table width="100%" cellpadding="0" cellspacing="1"
				class="BreadCrumb_OuterTableCSS">
				<tr>
					<td>
						<table width="100%" cellpadding="9" cellspacing="0"
							class="BreadCrumb_InnerTableCSS">
							<tr>

								<td>
									<a title="转向首页" class="SmlBoldLinks" href="index.jsp"><%=forumInfo.getSiteName()%>
									</a>
								</td>

								<td align="right" Class="SmallTxt" width="30%">
									<table cellpadding="0" cellspacing="0">
										<tr>
											<td Class="SmallTxt" id="new" nowrap="nowrap">
												<a class="SmlBoldLinks" href="">New主题</a>
												<script type="text/javascript"> vbmenu_register("new"); </script>
											</td>
											<td Class="SmallTxt">
												&nbsp;&nbsp;&nbsp;&nbsp;
											</td>
											<td Class="SmallTxt" id="hot" nowrap="nowrap">
												<a class="SmlBoldLinks" href="">Hot主题</a>
												<script type="text/javascript"> vbmenu_register("hot"); </script>
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>


			<font size="1"><br> </font>


			<!--板块与论坛显示 ----------------------------------------------------------------->
			<%
				//开始添加板块显示代码
				int boardid;
				//null时页面无内容
				if (boardList == null) {
					boardList = new ArrayList<BoardVo>();
				}
				//null时页面无内容
				if (forumList == null) {
					forumList = new ArrayList<ForumVo>();
				}
				//显示板块
				if (boardList != null) {
					Iterator<BoardVo> itboard = boardList.iterator();
					while (itboard.hasNext()) {
						BoardVo boardVo = itboard.next();
						boardid = boardVo.getBoardID();
			%>
			<table class="forum_out" width="100%" border="0" cellpadding="1"
				cellspacing="0">
				<tr>
					<td>
						<table cellpadding="5" width="100%" cellpadding="0"
							cellspacing="0">
							<tr>
								<td class="board" colspan="3" style="padding-left: 16px">
									<%=boardVo.getBoardName()%>
								</td>
								<script language="javascript" type="text/javascript">
								
										var list<%=boardid%>=new Array();		
                                        <%
                                        //用于实现折叠,该迭代器不能为全局变量
                                            Iterator<ForumVo> itforum = forumList.iterator();
											if (itforum != null) {
												int i=0;
										        while (itforum.hasNext()) {
											        ForumVo forumVo =  itforum.next();
											        if (boardid == forumVo.getBoardID()) {
								        %>				               
								        list<%=boardid%>[<%=i++%>]="fid"+<%=forumVo.getForumID()%>;
								        <%
								                }
								                }
								                }
								        %>  
                                </script>
								<td align="right" colspan="3" class="board">
									<img id="bid<%=boardVo.getBoardID()%>" title="展开/合起"
										unselectable="on"
										onclick="collapseForum(list<%=boardid%>,this.id)"
										src="images/ico/collapse.gif" border="0"
										style="Cursor: pointer;" alt="" />
								</td>
							</tr>
							<%
								Iterator<ForumVo> ittemp = forumList.iterator();
										if (ittemp != null) {
											while (ittemp.hasNext()) {
												ForumVo forumVoTemp = ittemp.next();
												if (boardid == forumVoTemp.getBoardID()) {
							%>
							<tr>
								<td align="center" style="width: 5%;" class="forumcell_read">
									&nbsp;
								</td>
								<td align="left" style="width: 50%;" class="forumcell_read">
									论坛
								</td>
								<td align="center" style="width: 8%;" class="forumcell_read">
									帖子
								</td>
								<td align="center" style="width: 8%;" class="forumcell_read">
									回复
								</td>
								<td align="center" style="width: 14%;" class="forumcell_read">
									最后发表
								</td>
								<td align="center" style="width: 21%;" class="forumcell_read">
									版主
								</td>
							</tr>

							<%
								break;
												}
											}
										}
							%>
							<%
								Iterator<ForumVo> ittemp2 = forumList.iterator();
										ittemp2 = forumList.iterator();
										if (ittemp2 != null) {
											while (ittemp2.hasNext()) {
												ForumVo forumData = ittemp2.next();
												if (boardid == forumData.getBoardID()) {
							%>
							<tr id="fid<%=forumData.getForumID()%>"
								onMouseOver="this.style.backgroundColor='#F5FBFF'"
								onMouseOut="this.style.backgroundColor='#FFFFFF'">
								<td align="center" class="forumcell_button">
									<img border="0" <%if(forumData.getTodayTopicNum()>0){%>
										title="今日有新贴" src="images/common.gif" <%}else{%> title="今日无新贴"
										src="images/ico/group.gif" <%} %> alt="" />
								</td>
								<td align="left" class="forumcell_button"
									style="line-height: normal;">
									<a class="forumlink"
										href="<%if (true) {%>forum.jsp?fid=<%=forumData.getForumID()%>&page=1<%}else{%>javascript:openErrorLogin();<%}%>"><%=forumData.getForumName()%></a>
									<font class="smalltext" color="blue">(<%=forumData.getTodayTopicNum()%>)</font>
									<font size="1"><br> </font>
									<font class="smalltext"><%=forumData.getAboutForum()%></font>
								</td>
								<td align="center" class="forumcell_button">
									<font class="smalltext"><%=forumData.getTopicNum()%></font>
								</td>
								<td align="center" class="forumcell_button">
									<font class="smalltext"><%=forumData.getPostNum()%></font>
								</td>
								<td align="center" class="forumcell_button">
									<font class="smalltext"><a
										title="发表时间:<%=forumData.getLastTopicDate()%>"
										href="<%if(true){%>topic.jsp?tid=<%=forumData.getLastTopicID()%><%}else{%>javascript:openErrorLogin();<%}%>"><%=forumData.getLastTopicTitle()%></a>
										<br> 发表人: <a
										title="发表时间:<%=forumData.getLastTopicDate()%>"
										href="<%if(true){%>topic.jsp?tid=<%=forumData.getLastTopicID()%><%}else{%>javascript:openErrorLogin();<%}%>"><%=forumData.getLastTopicAuthor()%></a>
									</font>
								</td>
								<td align="center" class="forumcell_button">
									<font class="smalltext"> <a title="" href="">暂无</a> </font>
								</td>
							</tr>
							<%
								}
											}
										}
							%>
						</table>
					</td>
				</tr>
			</table>


			<font size="1"><br> </font>
			<%
				}
				}
			%>
			<font size="1"><br> </font>


			<%
				//null时无显示
				if (linkList == null) {
					linkList = new ArrayList<LinkVo>();
				}
			%>
			<!--友情链接 ----------------------------------------------------------------->
			<table class="forum_out" width="100%" border="0" cellpadding="1"
				cellspacing="0">
				<tr>
					<td>
						<table cellpadding="5" width="100%" cellpadding="0"
							cellspacing="0">
							<tr>
								<td class="board" colspan="3" style="padding-left: 16px">
									友情链接
								</td>
								<td align="right" colspan="3" class="board">
								</td>
							</tr>
							<tr>

								<td align="left"
									style="padding-left: 15px; padding-top: 5px; padding-bom: 5px;"
									colspan="1">
									<%
										Iterator<LinkVo> itlink = linkList.iterator();
										while (itlink.hasNext()) {
											LinkVo link = itlink.next();
									%>
									<a class="smalltext" href="<%=link.getLinkurl()%>"
										title="<%=link.getAboutLink()%>" target="_blank"><font
										color="blue"> <%=link.getLinkname()%> </font> </a>&nbsp;&nbsp;
									&nbsp;&nbsp; &nbsp;&nbsp;
									<%
										}
									%>
								</td>

							</tr>
						</table>
					</td>
				</tr>
			</table>


			<font size="1"><br> </font>
			<font size="1"><br> </font>
			<font size="1"><br> </font>

			<!--页脚 ----------------------------------------------------------------->
			<%@include file="include/copyright.html"%>



			<font size="1"><br> </font>
		</div>


		<!--主题搜索 ----------------------------------------------------------------->
		<div class="vbmenu_popup" id="new_menu" style="display: none">
			<table cellpadding="4" cellspacing="1" border="0">
				<tr>
					<td class="thead" align="center">
						&nbsp;&nbsp;主题搜索&nbsp;&nbsp;
					</td>
				</tr>
				<tr>
					<td class="vbmenu_option" align="center">
						<a href="search.jsp?cond=today">&nbsp;&nbsp;今日主题&nbsp;&nbsp; </a>
					</td>
				</tr>
				<tr>
					<td class="vbmenu_option" align="center">
						<a href="search.jsp?cond=thisweek">&nbsp;&nbsp;本周主题&nbsp;&nbsp;
						</a>
					</td>
				</tr>
			</table>
		</div>
		<div class="vbmenu_popup" id="hot_menu" style="display: none">
			<table cellpadding="4" cellspacing="1" border="0">
				<tr>
					<td class="thead" align="center">
						&nbsp;&nbsp;主题搜索&nbsp;&nbsp;
						<br>
					</td>
				</tr>
				<tr>
					<td class="vbmenu_option" align="center">
						<a href="search.jsp?cond=top">&nbsp;&nbsp;置顶主题&nbsp;&nbsp; </a>
						<br>
					</td>
				</tr>
				<tr>
					<td class="vbmenu_option" align="center">
						<a href="search.jsp?cond=best">&nbsp; 精华主题&nbsp;&nbsp; </a>
						<br>
					</td>
				</tr>
			</table>
		</div>

		<!--登录窗口 ----------------------------------------------------------------->
		<%@include file="include/loginWindow.html"%>
		<script type="text/javascript">
			vBulletin_init();
		</script>

	</body>
</html>